#encoding=utf-8

require "nokogiri"
require "open-uri"
require 'ruby-pinyin'
require 'ostruct'
require "erb"



doc = Nokogiri::HTML(open("http://ylbook.com/cms/web/chuantongsecai/chuantongsecai.htm"));

interface = ""
implementation = ""

doc.css('dl').each do |element|

	color = element.css('dt')[0]
	c = OpenStruct.new
	c.name= color.text
	c.pinyin = PinYin.of_string(c.name).join

	value = element.css('span')[-1]
	c.value =  value.text.sub(/#/, "0X").upcase

	c.desc = element.css('.colorDesc')[0].text

	interface = interface + "
	//#{c.name}
	//#{c.desc}
	+(UIColor *) #{c.pinyin};
	"


	implementation = implementation +  "
	//#{c.name}
	//#{c.desc}
	+(UIColor *)#{c.pinyin}{
    return UIColorFromRGB(#{c.value});
	}
	"

end

puts implementation

